{{!
  Copyright (c) HashiCorp, Inc.
  SPDX-License-Identifier: BUSL-1.1
~}}

<SyncHeader
  @icon={{@destination.icon}}
  @title={{@destination.name}}
  @breadcrumbs={{array
    (hash label="Secrets Sync" route="secrets.overview")
    (hash label="Destinations" route="secrets.destinations")
    (hash label="Destination")
  }}
/>

<div class="tabs-container box is-bottomless is-marginless is-paddingless">
  <nav class="tabs" aria-label="destination tabs">
    <ul>
      <LinkTo @route="secrets.destinations.destination.secrets" data-test-tab="Secrets">Secrets</LinkTo>
      <LinkTo @route="secrets.destinations.destination.details" data-test-tab="Details">Details</LinkTo>
    </ul>
  </nav>
</div>

<Toolbar>
  <ToolbarActions>
    {{#if @destination.canDelete}}
      <Hds::Button
        data-test-toolbar="Delete destination"
        @text="Delete destination"
        @color="secondary"
        class="toolbar-button"
        {{on "click" (fn (mut this.isDeleteModalOpen) true)}}
      />
      {{#if (or @destination.canSync @destination.canEdit)}}
        <div class="toolbar-separator"></div>
      {{/if}}
    {{/if}}
    {{#if @destination.canSync}}
      <Hds::Button
        data-test-toolbar="Sync secrets"
        @text="Sync secrets"
        @icon="chevron-right"
        @iconPosition="trailing"
        @color="secondary"
        class="toolbar-button"
        @route="secrets.destinations.destination.sync"
      />
    {{/if}}
    {{#if @destination.canEdit}}
      <Hds::Button
        data-test-toolbar="Edit destination"
        @text="Edit destination"
        @icon="chevron-right"
        @iconPosition="trailing"
        @color="secondary"
        class="toolbar-button"
        @route="secrets.destinations.destination.edit"
      />
    {{/if}}
  </ToolbarActions>
</Toolbar>

<ConfirmationModal
  @title="Delete destination?"
  @onClose={{fn (mut this.isDeleteModalOpen) false}}
  @isActive={{this.isDeleteModalOpen}}
  @confirmText="DELETE"
  @toConfirmMsg="— this is case-sensitive."
  @onConfirm={{this.deleteDestination}}
>
  <p>
    The destination will be permanently deleted and all of its secrets will be un-synced. This cannot be undone.
  </p>
</ConfirmationModal>